package com.msb.strategy.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;
import java.util.Set;

/**
 * @Author: lmf
 * @Create: 2025/3/11 22:28
 * @module
 */
@FeignClient(value = "beacon-cache")
@RequestMapping("/cache")
public interface BeaconCacheClient {
    @GetMapping("hGet/{key}/{field}")
    String hGet(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field);

    @GetMapping(value = "/hGetInteger/{key}/{field}")
    Integer hGetInteger(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field);

    @GetMapping(value = "/exists/{key}")
    boolean exists(@PathVariable(value = "key") String key);

    @GetMapping(value = "/hGetAll/{key}")
    Map<String, Object> hGetAll(@PathVariable(value = "key") String key);

    /**
     * 获取有序集合
     */
    @GetMapping("/zrange/{key}/{start}/{end}")
    Integer zRangeByScoreCount(@PathVariable(value = "key") String key, @PathVariable(value = "start") Long min,
                               @PathVariable(value = "end") Long max);

    /**
     * 添加有序集合
     */
    @GetMapping("/zadd/{key}/{score}/{member}")
    boolean zadd(@PathVariable(value = "key") String key, @PathVariable(value = "score") Long score,
                 @PathVariable(value = "member") Long member);

    /**
     * 删除范围的有序集合
     */
    @GetMapping(value = "/zRemove/{key}/{start}/{member}")
    Long zRemoveRangeByScore(@PathVariable(value = "key") String key, @PathVariable(value = "start") long start,
                             @PathVariable(value = "member") long member);

    /**
     * 移除集合中的元素
     */
    @GetMapping(value = "/sRemove/{key}/{member}")
    Long sRemove(@PathVariable(value = "key") String key, @PathVariable(value = "member") long member);

    /**
     * 对map集合key进行自增操作
     */
    @GetMapping(value = "/hIncrement/{key}/{field}/{delta}")
    public Long hIncrement(@PathVariable(value = "key") String key,
                           @PathVariable(value = "field") String field,
                           @PathVariable(value = "delta") Long delta);

    @GetMapping(value = "/get/{key}")
    String getString(@PathVariable(value = "key") String key);


    @GetMapping(value = "/sMembers/{key}")
    Set<String> sMembersString(@PathVariable(value = "key") String key);

    /**
     * 获取set集合
     */
    @GetMapping(value = "/sMembersToMap/{key}")
    Set<Map> sMembersToMap(@PathVariable(value = "key") String key);
}
